package com.wuhuiyue.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wuhuiyue.entity.Result;
import com.wuhuiyue.entity.Seartch;
import com.wuhuiyue.entity.Softwarevo;
import com.wuhuiyue.service.ISoftwarevoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * VIEW 前端控制器
 * </p>
 *
 * @author hy-woo
 * @since 2022-06-11
 */
@RestController
@RequestMapping("/softwarevo")
public class SoftwarevoController {

    @Autowired
    ISoftwarevoService softwarevoService;

    @RequestMapping("/page")
    public Result page(@RequestBody Seartch seartch){
        Page<Softwarevo> softwarevoPage = new Page<>(seartch.getPage(), seartch.getPageSize());
        QueryWrapper<Softwarevo> wrapper = new QueryWrapper<>();
        if (StringUtils.hasText(seartch.getGname())){
            wrapper.like("gname",seartch.getGname());
        }
        if (seartch.getFid()!=null){
            wrapper.eq("fid",seartch.getFid());
        }
        if (seartch.getDatea()!=null){
            wrapper.gt("created",seartch.getDatea());
        }
        if (seartch.getDateb()!=null){
            wrapper.lt("created",seartch.getDateb());
        }
        Page<Softwarevo> page = softwarevoService.page(softwarevoPage, wrapper);
        return Result.OK(page);
    }
}
